package com.example.wjy.viewmodels;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;

import com.example.room.entity.Master;
import com.example.room.entity.TeamMember;
import com.example.room.repository.TeamMemberRepository;

import java.util.ArrayList;
import java.util.List;

public class MemberViewModel extends AndroidViewModel {
    MutableLiveData<List<Master>> masterList;

    TeamMemberRepository repository;
    public MemberViewModel(@NonNull Application application) {
        super(application);
        repository = new TeamMemberRepository(application);

    }

    public LiveData<List<TeamMember>> getAllTeamMember() {
        return repository.getAllTeamMember();
    }

    public void insertTeamMember(TeamMember... teamMembers) {
        repository.insertTeamMember(teamMembers);
    }

    public void deleteAllMaster() {
        repository.deleteAllMaster();
    }
    public MutableLiveData<List<Master>> getMasterList() {
        if(masterList == null){
            masterList = new MutableLiveData<>();
            masterList.setValue(new ArrayList<>());
        }

        return masterList;
    }
}
